﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace QW.Core.Events
{
    /// <summary>
    /// 事件发布者
    /// </summary>
    public interface IEventPublisher : IDisposable
    {
        /// <summary>
        /// 发布事件异步
        /// <para>默认实现异步暂时会报外部错误,估计是await的地方有问题</para>
        /// </summary>
        /// <typeparam name="TEvent"></typeparam>
        /// <param name="event"></param>
        /// <returns></returns>
        [Obsolete("默认实现异步暂时会报外部错误，请使用Publish")]
        Task PublishAsync<TEvent>(TEvent @event) where TEvent : class, IEvent;
        /// <summary>
        /// 同步事件同步
        /// </summary>
        /// <typeparam name="TEvent"></typeparam>
        /// <param name="event"></param>
        void Publish<TEvent>(TEvent @event) where TEvent : class, IEvent;
    }
}
